<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateFsUsersCompanysTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('fs_company_users', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('rmsUserId')->default(0)->comment('rms-userId');
            $table->string('appId', 32)->default('')->comment('飞书-appId');
            $table->string('feishuId', 32)->default('')->comment('飞书-userId');
            $table->string('name', 32)->default('')->comment('用户名');
            $table->string('phone', 32)->default('')->comment('手机号');
            $table->string('openId',64)->default('')->comment('飞书-openId');
            $table->string('unionId', 64)->default('')->comment('飞书-unionId');
            $table->string('avatar', 255)->default('')->comment('头像');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '不同企业下的飞书用户信息';

            $table->index(['rmsUserId', 'appId'], 'idx_rmsUserId');
            $table->index('feishuId', 'idx_feishuId');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('fs_company_users');
    }
}
